home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Info-Mac 3
/
Info_Mac_1994-01.iso
/
Graphics
/
Utility
/
GL Viewer 1.1.1
/
src ƒ
/
macinit.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-08-25
|
5KB
|
203 lines
/*
macmain.c
-- Macintosh initializations, then call real main
//Note: compile this segment as Main for generic 68000 processor, so it won't
// fail on generic mac
*/
#pragma segment Main
#include <Palette.h>
#include <console.h>
#include "grasp.h"
#include "procImage.h"
#include "macPrefs.h"
static void InitMac (void);
extern void InitExec (void);
//#define VERSION curSysEnvVers
#define nocolorID 130
#define no68020 133
#define no68881 132
#define no256 134
#define nosys6 135
static void
MacInit (void)
{
SysEnvRec theWorld;
OSErr OSys;
DialogPtr crashDia;
long tick;
cshow (stdin);
console_options.pause_atexit = 0;
InitMac ();
InitExec ();
/*______________________________________________________*/
/* If not right Machine then stop */
/*______________________________________________________*/
OSys = SysEnvirons( curSysEnvVers,&theWorld);
if(!theWorld.hasColorQD) {
crashDia = GetNewDialog (nocolorID, nil, (WindowPtr) -1);
DrawDialog (crashDia);
Delay (300, &tick);
ExitToShell();
}
if(theWorld.processor < env68020) {
crashDia = GetNewDialog (no68020, nil, (WindowPtr) -1);
DrawDialog (crashDia);
Delay (300, &tick);
ExitToShell();
}
/*if(!theWorld.hasFPU) {
crashDia = GetNewDialog (no68881, nil, (WindowPtr) -1);
DrawDialog (crashDia);
Delay (300, &tick);
ExitToShell();
}
if(theWorld.systemVersion < 0x0600) {
crashDia = GetNewDialog (nosys6, nil, (WindowPtr) -1);
DrawDialog (crashDia);
Delay (300, &tick);
ExitToShell();
}*/
#ifdef UnDeFineD
/*______________________________________________________*/
/* Set Rects */
/*______________________________________________________*/
screenRect = qd.screenBits.bounds;
offLeft = 0;
offTop = 0;
offRight = screenRect.right;
offBottom = screenRect.bottom;
SetRect(&BaseRect, 40, 60, 472, 282);
tempRgn = GetGrayRgn();
HLock ((Handle) tempRgn);
TotalRect = (**tempRgn).rgnBBox;
SetRect(&minRect, 80, 80, (**tempRgn).rgnBBox.right - 40,
(**tempRgn).rgnBBox.bottom - 40);
HUnlock ((Handle) tempRgn);
/*______________________________________________________*/
/* Open Window & set Palette & Picture */
/*______________________________________________________*/
theGDevice = GetMainDevice();
HLock ((Handle) theGDevice);
mycolors = (**(**theGDevice).gdPMap).pmTable;
numcolor = (**(**theGDevice).gdPMap).pixelSize;
HUnlock((Handle) theGDevice);
switch (numcolor) {
case 1:
numcolor = 2;
break;
case 2:
numcolor = 4;
break;
case 4:
numcolor = 16;
break;
case 8:
numcolor = 256;
break;
}
myWindow = NewCWindow(nil, &BaseRect, "\p", TRUE, zoomDocProc,
(WindowPtr) -1, TRUE, 150);
SetPort((WindowPtr) myWindow);
DrawGrowIcon (myWindow);
srcPalette = NewPalette (numcolor, mycolors, pmCourteous, 0);
SetPalette ((WindowPtr) myWindow, srcPalette, TRUE);
/*______________________________________________________*/
/* Set menus */
/*______________________________________________________*/
mymenu0 = GetMenu(appleID);
AddResMenu(mymenu0, 'DRVR');
InsertMenu(mymenu0,0);
mymenu1 = newmenu(129,"File");
appendmenu(mymenu1,"Start;Quit");
InsertMenu(mymenu1,0);
mymenu2 = newmenu(130,"Edit");
InsertMenu(mymenu2,0);
DrawMenuBar();
/*______________________________________________________*/
/* Init variables */
/*______________________________________________________*/
DoneFlag = FALSE;
yieldTime = 0;
return;
#endif
}
extern int real_main(int argc, char *argv[]);
main(int argc, char *argv[])
{
MacInit();
real_main(argc, argv);
}
int
getpid ()
{
return TickCount ();
}
#define SET_PREF(fFlag, thePref) \
thePref = (prefs & fFlag) ? True : False;
static void
InitMac (void)
{
Handle hPrefs;
u_char prefs = ePrefQuiet;
u_char fTmpVideoC;
if ((hPrefs = GetResource (MACPREFS_RESTYPE, MACPREFS_RESID))
/* != (Handle) NULL */ &&
ResError () == noErr)
{
prefs = ** (u_char **) hPrefs;
ReleaseResource (hPrefs);
}
if (cmdKeyIsDown ())
prefs = DoMacPrefsDialog (prefs);
SET_PREF (ePrefSmallVideoC , fTmpVideoC);
SET_PREF (ePrefImageloop , imageloop);
SET_PREF (ePrefShowDirectory, showdirectory);
SET_PREF (ePrefShowText , showtext);
SET_PREF (ePrefPrintTheCodes, printthecodes);
SET_PREF (ePrefQuiet , fQuiet);
SET_PREF (ePrefVerbose , verbose);
SET_PREF (ePrefImVerbose , imverbose);
InitVideoC (fTmpVideoC);
}